<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/WEB-INF/template_admin.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListPrestamoTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <p:growl id="growl" life="3000"/>

            <p:panel id="panel" header="Prestamos" styleClass="panel" style="width: 600px">
                <h:form styleClass="jsfcrud_list_form">
                    <h:outputText escape="false" value="#{bundle.ListPrestamoEmpty}" rendered="#{prestamoController.items.rowCount == 0}"/>
                    <h:panelGroup rendered="#{prestamoController.items.rowCount > 0}">
                        <p:dataTable value="#{prestamoController.items}" var="item" emptyMessage="No se encontraron registros con ese criterio"
                                     widgetVar="userTable" paginator="true" rows="5" 
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     rowsPerPageTemplate="5,10,20">
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="&nbsp;"/>
                                </f:facet>
                                <h:commandLink action="#{prestamoController.prepareEdit}" title="Editar">
                                    <img src="../../images/b_edit.png" width="16" height="16" alt="b_edit"/>
                                </h:commandLink>
                                <p:commandLink title="Eliminar" update=":growl" onclick="cd.show()" style="text-decoration: none">
                                    <img src="../../images/b_drop.png" width="16" height="16" alt="b_drop"/>
                                </p:commandLink>
                                <p:confirmDialog message="¿Está seguro de querer eliminar el registro?"
                                                 header="Iniciando proceso de eliminación" severity="alert"
                                                 widgetVar="cd">
                                    <p:commandButton value="Si" actionListener="#{prestamoController.destroy}"
                                                     update=":growl" onclick="cd.hide()"/>
                                    <p:commandButton value="No" onclick="cd.hide();" type="button" />
                                </p:confirmDialog>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestFecha}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestFecha}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss a" />
                                </h:outputText>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestFechaDev}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestFechaDev}">
                                    <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss a" />
                                </h:outputText>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestEstado}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestEstado}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestIdEje}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestIdEje}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestIdTp}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestIdTp}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_prestIdSolicitante}"/>
                                </f:facet>
                                <h:outputText value="#{item.prestIdSolicitante}"/>
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="#{bundle.ListPrestamoTitle_multaPrestamo}"/>
                                </f:facet>
                                <h:outputText value="#{item.multaPrestamo}"/>
                            </p:column>
                        </p:dataTable>
                    </h:panelGroup>
                    <br />
                    <p:commandButton action="#{prestamoController.prepareCreate}" value="#{bundle.ListPrestamoCreateLink}" update=":growl, :panel" icon="ui-icon-check"/>
                    <br />
                    <br />
                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>

</html>
